package com.sojson.util.id.impl;

import java.util.UUID;

import com.sojson.util.StringUtil;
import com.sojson.util.id.GUIDUtilInterface;

/**
 * GUID工具类
 * 
 * @author liu
 * @Date 2020-07-09 15:15:14
 * @Description
 *
 */
public class UUIDUtilImpl implements GUIDUtilInterface {

    private static UUIDUtilImpl uUIDUtilImpl;

    private UUIDUtilImpl() {}

    /**
     * 生成全局唯一的ID
     * 
     * @return
     */
    @Override
    public String generateGuid() {
        return UUID.randomUUID().toString().replace("-", "").toUpperCase();
    }

    /**
     * 判断一个对象是否是空(空对象)
     * 
     * @param obj
     * @return
     */
    private static boolean isBlankObject(Object obj) {
        return StringUtil.isBlankObject(obj);
    }

    public static UUIDUtilImpl getInstances() {
        if (isBlankObject(uUIDUtilImpl)) {
            uUIDUtilImpl = new UUIDUtilImpl();
        }
        return uUIDUtilImpl;
    }

}